home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7701 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.5 KB  |  80 lines

  1. Path: news.unt.edu!news
  2. From: Steve Fogoros <sfogoros@hsc.unt.edu>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Keyboard lights.
  5. Date: Tue, 27 Feb 1996 20:00:26 -0800
  6. Organization: University of North Texas Health Science Center
  7. Message-ID: <3133D35A.2947@hsc.unt.edu>
  8. References: <4gvi6u$7qf@bertrand.ccs.carleton.ca>
  9. NNTP-Posting-Host: sfogoros.hsc.unt.edu
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0b6a (Win16; I)
  14.  
  15. Evan Hughes wrote:
  16. >   Where is the status byte for the ...
  17.  
  18. Hope you don't mind I sent the whole thing:
  19.  
  20. /* setlocks.c - program for setting num, caps, scroll lock keys */
  21. /*              assumes PC/DOS type computer
  22.  
  23. #include "dos.h"
  24. #include "stdio.h"
  25. #include "string.h"
  26. #include "stdlib.h"
  27.  
  28. #define LOCKADDR_SEG 0x0040
  29. #define LOCKADDR_OFF 0x0017
  30.  
  31. main(int argc, char *argv[])
  32. {
  33.    char c, status[80];
  34.  
  35.    c = peekb(LOCKADDR_SEG,LOCKADDR_OFF);
  36.  
  37.    if(argc != 3 || argv[1][0] == '-')
  38.    {
  39.       status[0] = 0;
  40.       if(c & 0x20) strcat(status,"Num on, "); else strcat(status,"Num off, ");
  41.       if(c & 0x40) strcat(status,"Cap on, "); else strcat(status,"Cap off, ");
  42.       if(c & 0x10) strcat(status,"Scr on, "); else strcat(status,"Scr off, ");
  43.       if(c & 0x80) strcat(status,"Ins on"); else strcat(status,"Ins off");
  44.       prthelp(status);
  45.    }
  46.  
  47.    strlwr(argv[1]);
  48.    strlwr(argv[2]);
  49.  
  50.    switch(argv[1][0])
  51.    {
  52.       case 'n': if(argv[2][1] == 'n') c = c | 0x20; else c = c & 0xdf; break;
  53.       case 'c': if(argv[2][1] == 'n') c = c | 0x40; else c = c & 0xbf; break;
  54.       case 's': if(argv[2][1] == 'n') c = c | 0x10; else c = c & 0xef; break;
  55.       case 'i': if(argv[2][1] == 'n') c = c | 0x80; else c = c & 0x7f; break;
  56.    }
  57.  
  58.    pokeb(LOCKADDR_SEG,LOCKADDR_OFF,c);
  59. }
  60.  
  61. prthelp(char *status)
  62. {
  63. printf("\nusage: setlocks [ [num on|off] [cap on|off] [scr on|off] [ins on|off] ]\n\n");
  64. printf("setlocks is used to set or reset the named keyboard lock. Handy when used\n");
  65. printf("in a batch file. Only one lock may be changed at a time.\n\n");
  66. printf("ex. setlocks n on\n");
  67. printf("    setlocks ca off\n");
  68. printf("    setlocks ins on\n\n");
  69. printf("Only the first char is looked at to tell which lock has been selected.\n");
  70. printf("Only the second char of command is looked at to tell on or off.\n\n");
  71. printf("Actual settings are %s\n",status);
  72. exit(0);
  73. }
  74. -- 
  75. Steve Fogoros, Academic Information Coordinator
  76. University of North Texas Health Science Center
  77. 3500 Camp Bowie Boulevard, Fort Worth, Texas 76107-2699
  78. (817)-735-2162 sfogoros@hsc.unt.edu
  79.